<?php

namespace App\Http\Controllers\Backend;

use App\Events\Upload;
use App\Http\Controllers\Controller;
use App\Models\FileTransaction;
use App\Models\Video;
use App\Traits\WithUploadFile;

class UploadController extends Controller
{

    use WithUploadFile;

    public function upload()
    {
        $fileKeys = array_keys(request()->file());
        $result = $this->uploadFile($fileKeys);
        return json_encode($result);
    }

    public function queue()
    {
        $video = Video::with(['videoing.config'])->get();
        $video->each(function (FileTransaction $transaction) {
            event(new Upload($transaction));
        });
    }
}
